package {
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	import flash.external.ExternalInterface;
	import flash.net.URLRequest;
	import flash.net.navigateToURL;
	
	import flower.Bone;
	import flower.Cloth;
	import flower.GoodsInfo;
	[SWF(width=66, height=110, frameRate=30,backgroundColor=0x530000)]
	public class Fairy extends Sprite
	{
		public static var bone:MovieClip
		public static var body:Sprite
		public static var Info
		public static var thisroot
		//public static var IP:String="http://hua.61.com"
		public static var IP:String="http://huatest.61.com.tw"
		public static var rooturl=IP+"/resource/bone/swf/"
		//public static var rooturl="resource/bone/swf/"
		
		private static var uid:uint;
		private static var navigateURL:String;
		
		public function Fairy()
		{
			thisroot=this
			Info=new Object()
			body=new Sprite()
			addChild(body)
			GoodsInfo.loadItemData()
			
		}
		
		public static function init():void{
			var p:Object=thisroot.loaderInfo.parameters
			
//			var t:TextField=new TextField()
//			thisroot.addChild(t)
//			t.appendText("user_id:"+p.userid+"\n")
			
			var User_Nationality=p.nationality
			var User_FaceColor=p.skin
			var arr:Array=initcloth(User_Nationality)
			for(var i in p){
				
				if(p[i]>100000 && i !="sessionID" && i != "uid" && i != "userid" && i != "usernick"){
					arr.push(p[i])
//					t.appendText("user_cloth:"+p[i]+"\n")
				}
			}
			var boneui=new UI_Fairy_static_show()
			if(User_Nationality==5){
				boneui=new UI_Fairy_static_man()
				bone=Bone.MakeBone(User_FaceColor-1200000,30,45,1,false,boneui)
			}else{
				bone=Bone.MakeBone(User_FaceColor-1200000,30,55,1,false,boneui)
			}
			body.addChild(bone);
			
			var gp:Sprite = new Sprite();
			gp.graphics.beginFill(0xFFFFFF,0);
			gp.graphics.drawRect(0,0,66,100);
			gp.graphics.endFill();
			body.addChild(gp);
			
			if(p.uid)
			{
				uid = p.uid;
				navigateURL = p.url;
				body.buttonMode = true;
				thisroot.addEventListener(MouseEvent.MOUSE_DOWN,boneClick);
			}
			//var arr:Array=initcloth(Info)
			//arr=[100007,100466,100939,100468,100940,100467,100013,100942,600036,600005,600003,600008,600004,100935,0,100465,0,0]
			//oldcloth=clone(arr)
			var cloth=new Cloth(arr,bone.ff.bone,false)
			//FairyAction.Floating(bone)
			//BodyViews= new BodyView();
			//BodyViews.show(bone.ff.bone,LocalInfo.OnLineInfo);	 */
		}
		
		private static function boneClick(e:MouseEvent):void
		{
			if(ExternalInterface.available)
			{
				navigateToURL(new URLRequest("http://"+navigateURL+"/huadressup/detail?uid="+uid));
			}
		}
		
		
		public static function initcloth(User_Nationality:Object):Array
		{
			var Arr:Array=new Array()
			if(User_Nationality==1){
				Arr.push(600001);
			}else if(User_Nationality==2){
				Arr.push(600036);
			}else if(User_Nationality==3){
				Arr.push(600037);
			}else if(User_Nationality==4){
				Arr.push(600075);
			}else if(User_Nationality==5){
				Arr.push(600127);
			}
			
			//国家 。触角
			//Arr.push(info.FaceColor);
			//身体颜色
			/* Arr.push(info.User_Face);
			Arr.push(info.User_Eye);
			Arr.push(info.User_Eyebrow);
			Arr.push(info.User_Lip);
			
			Arr.push(info.User_Tool);
			Arr.push(info.User_Headdress);
			Arr.push(info.User_Mask);
			Arr.push(info.User_Hair);
			Arr.push(info.User_Earring);
			Arr.push(info.User_Necklace);
			Arr.push(info.User_Belt);
			Arr.push(info.User_Cloth);
			Arr.push(info.User_Bangle);
			Arr.push(info.User_Shoes);
			Arr.push(info.User_Anklet);
			Arr.push(info.User_Skirt);
			Arr.push(info.User_Wing);
			//Arr.push(info.User_Trousers); */
			return Arr
		}
	}
}
